<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" th:href="@{/css/oksub.css}">
</head>
<body>
<div class="layui-container" style="margin-top: 20px">
    <form class="layui-form layui-form-pane" lay-filter="staffFrom">

        <div class="layui-form-item">
            <label class="layui-form-label">登录账号</label>
            <div class="layui-input-block">
                <input type="text" name="loginAccount" lay-verify=""
                       placeholder="请输入员工登录账号" autocomplete="off" class="layui-input" readonly="readonly" th:value="${session.staff.loginAccount}" th:readonly="readonly" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">登录密码</label>
            <div class="layui-input-block">
                <input type="text" name="loginPassword" lay-verify=""
                       placeholder="请输入员工登录密码" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">员工名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="required"
                       placeholder="请输入员工名称" autocomplete="off" class="layui-input" th:value="${session.staff.name}">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="staffFrom">提交</button>

            </div>
        </div>

        <div style="height: 200px"></div>
    </form>
</div>

<script type="text/javascript" th:src="@{/lib/layui/layui.js}"></script>

<script type="text/javascript">
    layui.use(['form', 'layer', 'element', 'laydate', 'jquery'],
        function () {
            $ = layui.jquery;
            form = layui.form;
            layer = layui.layer;
            element = layui.element;

            //监听表单提交事件
            form.on('submit(staffFrom)', function (data) {
                var index = top.layer.msg('数据提交中，请稍候', {
                    icon: 16,
                    time: false,
                    shade: 0.8
                });
                var params = data.field;

                $.post("/api/staff/update", params, function (d) {
                    if (d.code == 200) {
                        top.layer.close(index);
                        top.layer.msg("操作成功！");
                        layer.closeAll("iframe");
                        //刷新父页面
                        parent.location.reload();
                    } else {
                        top.layer.close(index);
                        layer.msg(d.msg, {
                            "icon": 2
                        });
                    }
                });

                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });

        });
</script>
</body>


</html>